<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript">
        window.onload=function()
        {
            //声明一个set
            let s=new Set();
            let s2=new Set(["123","456","789","123","147","456"]);
            console.log(s,typeof s);
            //在传入了参数的Set()实例对象，控制台输出的时候会给数组的元素进行去重
            console.log(s2);
            console.log(s2.size);
            //输出的实例对象长度也是去重后计算的
            //添加新的元素
            s2.add("999");
            console.log(s2);
            //删除元素
            s2.delete("123");
            console.log(s2);
            //检测是否存在目标元素
            console.log(s2.has("123"));
            console.log(s2.has("789"));
            //清空元素
            /*
            s2.clear();
            console.log(s2);
            */
            for(let v of s2)
            {
                console.log(v);
            }
        };
    </script>
</head>
<body>
    
</body>
</html>